// -----------------------------------------
// tests1.js
// Fuchsia unit tests
// -----------------------------------------

// -----------------------------------------
function setUp() {
	
}

function tearDown() {
	// Ensure all notes are deleted
	Fuchsia.activeNotes.deleteAll();
	$(".note").remove();
}

// -----------------------------------------
// Test the Info object
function testInfo() {
	assertNotNull(Info);
	assertEquals("fuchsia", Info.name);
	assert(Info.aboutText().length > 0);
}

// -----------------------------------------
// Test the CommandMenu class
function testCommandMenu() {
	var p = new CommandMenu([]);
	assertNotNull(p);
}

// -----------------------------------------
// Test the WordList object
function testWordList() {
	assertNotNull(WordList);
	var w1 = WordList.random();
	assert(w1.length > 0);
	var w2 = WordList.random();
	assertNotEquals(w1, w2);
}

// -----------------------------------------
// Test the IdGenerator class
function testUniqueId() {
	var g = new IdGenerator();
	assertNotNull(g);
	var x = g.next();
	assertEquals("n", x.substring(0, 1));
	var y = g.next();
	assertNotEquals(x, y);
}

// -----------------------------------------
// Test the Note class
function testNote() {
	var n1 = new Note();
	assertNotNull(n1);
	assertEquals("(empty)", n1.text);
	assertEquals(Fuchsia.prefs.defaultColour, n1.colour);
	assert(n1.x > 0);
	
	var n2 = new Note("abcdef");
	assertEquals("abcdef", n2.text);
	n2.cycleColour();
	assertEquals(1, n2.colour);
	n2.setColour(Fuchsia.numColours - 1);
	n2.cycleColour();
	assertEquals(0, n2.colour);
}

// -----------------------------------------
// Test the Fuchsia object
function testFuchsia() {
	Fuchsia.addNote("abcdef");
}

// -----------------------------------------
// The End
